********************************************************************************
** Communicating doctors' consensus persistently increases Covid-19 vaccinations
** Master do file
********************************************************************************

* Currently programmed for Stata 17
* For an earlier version, change number accordingly in the following:
version 17

* Version history
* 7.4.2022 Vojta

clear all
set more off
global date 210930
set seed 840801
global seed_number 840801
* installs lean2 scheme if not already installed
capture findfile lean2.scheme 	
if _rc==601 {
	net install gr0002_3, from("http://www.stata-journal.com/software/sj4-3")
	}
set scheme lean2

** Set Directories *************************************************************

* For MacOS
if "`c(username)'" == "vojtabartos" { 
	global dropbox "/Users/vojtabartos/Dropbox/CZ Covid and scapegoating/5_paper/4_vaccine_info_exp/Journal submissions/Nature/final submission/replication files/" 
	}
* For Windows
if "`c(username)'" == "cahj" { 
	global dropbox "C:\Users\cahj\Dropbox\CZ Covid\1_analysis" 
	}
/* Others: use the code snippet to set your working directory: need to change your username & path
if "`c(username)'" == "vojtabartos" { 
	global dropbox "/Users/vojtabartos/Dropbox/CZ Covid and scapegoating/5_paper/4_vaccine_info_exp/Journal submissions/Nature/final submission/replication files/" 
	}	
*/
	
global rawdatapath "$dropbox/0_raw_data"
global cleandatapath "$dropbox/1_clean_data"
global dopath "$dropbox/2_do_files/communicating_consensus"
global logpath "$dropbox/3_log_files/communicating_consensus"
global outputpath "$dropbox/4_output/communicating_consensus"


* Programs required ************************************************************

* All programs that need to be installed to be listed here together with install command (ssc install xxx)
local required_ados "orth_out ritest specc" //add the required ados here//
foreach x of local required_ados {
	capture findfile `x'.ado		
	if _rc==601 {
	ssc install `x', replace
	}
}

capture findfile grc1leg.ado		
if _rc==601 {
	net from http://www.stata.com
    net cd users
    net cd vwiggins
    net install grc1leg
}	

** General options *************************************************************

* e.g., global / local lists of variables to be defined here
global esttab_opt_stats "stats(N, fmt(0) labels("Observations"))"
global cells "compress b(%3.2f) se(%3.2f) star(* 0.10 ** 0.05 *** 0.01) noomit nobase drop(`covars')"
global tex "collabels(,none)"

global vaccination_controls female d_age_cat2 d_age_cat3 d_age_cat4 d_age_cat5 d_age_cat6 hsize children children_missing d_region2 d_region3 d_region4 d_region5 d_region6 d_region7 d_region8 d_region9 d_region10 d_region11 d_region12 d_region13 d_region14 d_townsize2 d_townsize3 d_townsize4 d_townsize5 d_townsize6 d_townsize7 d_educ2 d_educ3 d_educ4 d_estat2 d_estat3 d_estat4 d_estat5 d_estat6 d_estat7 d_HHincome2 d_HHincome3 d_HHincome4 d_HHincome5 d_HHincome6 d_HHincome7 d_HHincome8 d_HHincome9 d_HHincome10 d_HHincome11  vaccineyesprior vaccineyesprior_missing vaccinated25

global vaccination_controls_belief $vaccination_controls belief_takeup25 belief_trust25

global vaccination_controls_pap female d_age_cat2 d_age_cat3 d_age_cat4 d_age_cat5 d_age_cat6 hsize children children_missing d_region2 d_region3 d_region4 d_region5 d_region6 d_region7 d_region8 d_region9 d_region10 d_region11 d_region12 d_region13 d_region14 d_townsize2 d_townsize3 d_townsize4 d_townsize5 d_townsize6 d_townsize7 d_educ2 d_educ3 d_educ4 d_estat2 d_estat3 d_estat4 d_estat5 d_estat6 d_estat7 d_HHincome2 d_HHincome3 d_HHincome4 d_HHincome5 d_HHincome6 d_HHincome7 d_HHincome8 d_HHincome9 d_HHincome10 d_HHincome11 vaccineyesprior vaccineyesprior_missing

label define yes_no 0 "No" 1 "Yes"

** Run files *******************************************************************
* This part runs all do files from the raw data cleaning all the way to producing final output (tables, figures, statistics)

* 1. Import and prepare clean data set
do "$dopath/01_data_clean"

* 2. Main analysis
do "$dopath/02_all_results"
